package c.c.a;

import android.content.ContentValues;
import android.database.Cursor;
import android.util.Log;
import com.bytedance.embedapplog.AppLog;
import com.huawei.hms.jos.games.player.GameTrialConstant;
import org.json.JSONArray;
import org.json.JSONObject;

public class z extends s {
    public byte[] i;
    public int j;
    public int k;
    public JSONArray l;
    public JSONArray m;
    public y n;
    public JSONArray o;
    public d0 p;
    public JSONObject q;
    public JSONArray r;

    public s a(Cursor cursor) {
        this.a = cursor.getLong(0);
        this.i = cursor.getBlob(1);
        this.j = cursor.getInt(2);
        this.q = null;
        this.n = null;
        this.p = null;
        this.o = null;
        this.l = null;
        this.m = null;
        this.r = null;
        return this;
    }

    public void b(ContentValues contentValues) {
        contentValues.put("local_time_ms", Long.valueOf(System.currentTimeMillis()));
        contentValues.put("_data", AppLog.toEncryptByte(j().toString()));
    }

    public void c(JSONObject jSONObject) {
        m0.b(null);
    }

    public String[] d() {
        return new String[]{"local_time_ms", "integer", "_data", "blob", "_fail", "integer", "_full", "integer"};
    }

    public s f(JSONObject jSONObject) {
        m0.b(null);
        return null;
    }

    public JSONObject g() {
        JSONArray jSONArray;
        JSONArray jSONArray2;
        int length;
        JSONArray jSONArray3;
        int i;
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("magic_tag", "ss_app_log");
        jSONObject.put("header", this.q);
        jSONObject.put("time_sync", q.b);
        if (this.n != null) {
            jSONArray = new JSONArray();
            jSONArray.put(this.n.j());
            jSONObject.put("launch", jSONArray);
        }
        d0 d0Var = this.p;
        int i2 = 0;
        if (d0Var != null) {
            JSONObject j = d0Var.j();
            jSONArray2 = this.o;
            length = jSONArray2 != null ? jSONArray2.length() : 0;
            jSONArray3 = new JSONArray();
            for (int i3 = 0; i3 < length; i3++) {
                JSONArray jSONArray4 = new JSONArray();
                JSONObject jSONObject2 = new JSONObject(new JSONObject(this.o.optString(i3)).optString("params"));
                jSONArray4.put(0, jSONObject2.optString("page_key", ""));
                jSONArray4.put(1, (jSONObject2.optInt("duration", 0) + 999) / 1000);
                jSONArray3.put(jSONArray4);
            }
            if (length > 0) {
                j.put("activites", jSONArray3);
            }
            jSONArray2 = new JSONArray();
            jSONArray2.put(j);
            jSONObject.put("terminate", jSONArray2);
        }
        jSONArray = this.l;
        int length2 = jSONArray != null ? jSONArray.length() : 0;
        if (length2 > 0) {
            jSONObject.put(GameTrialConstant.NOTIFY_EVENT_KEY, this.l);
        }
        jSONArray2 = this.o;
        length = jSONArray2 != null ? jSONArray2.length() : 0;
        if (this.m == null) {
            this.m = this.o;
        } else if (length > 0) {
            for (i = 0; i < length; i++) {
                this.m.put(this.o.get(i));
            }
        }
        jSONArray3 = this.m;
        i = jSONArray3 != null ? jSONArray3.length() : 0;
        if (i > 0) {
            jSONObject.put("event_v3", this.m);
        }
        JSONArray jSONArray5 = this.r;
        if (jSONArray5 != null) {
            i2 = jSONArray5.length();
        }
        if (i2 > 0) {
            jSONObject.put("log_data", this.r);
        }
        StringBuilder stringBuilder = new StringBuilder("wP {");
        Object obj = this.n;
        if (obj == null) {
            obj = "la";
        }
        stringBuilder.append(obj);
        stringBuilder.append(", ");
        obj = this.p;
        if (obj == null) {
            obj = "te";
        }
        stringBuilder.append(obj);
        stringBuilder.append(", p: ");
        stringBuilder.append(length);
        stringBuilder.append(", v1: ");
        stringBuilder.append(length2);
        stringBuilder.append(", v3: ");
        stringBuilder.append(i);
        String str = "}";
        stringBuilder.append(str);
        stringBuilder.append(", m: ");
        stringBuilder.append(i2);
        stringBuilder.append(str);
        Log.i("TeaLog", stringBuilder.toString(), null);
        return jSONObject;
    }

    public String i() {
        return "pack";
    }

    public void m(long j, JSONObject jSONObject, y yVar, d0 d0Var, JSONArray jSONArray, JSONArray jSONArray2, JSONArray jSONArray3, JSONArray jSONArray4) {
        this.a = j;
        this.q = jSONObject;
        this.n = yVar;
        this.p = d0Var;
        this.o = jSONArray;
        this.l = jSONArray2;
        this.m = jSONArray3;
        this.r = jSONArray4;
    }
}
